package essential.ch3;

/**
 * @Date 2021/10/23
 * @Created by Jonathan
 * equals到底比较什么?
 * <p>
 * 在没有重写的情况下就是调用下面这段方法 实际上就是==
 * public boolean equals(Object obj) {
 * return (this == obj);
 * }
 */
public class StringEquals {
    public static void main(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("abc");
        StringBuilder builder1 = new StringBuilder("abc");
        StringBuilder builder2 = new StringBuilder("abc");
        StringBuffer buffer1 = new StringBuffer("abc");
        StringBuffer buffer2 = new StringBuffer("abc");
        System.out.println(s1.equals(s2));
        System.out.println(builder1.equals(builder2));
        System.out.println(buffer1.equals(buffer2));
    }
}
